//
// Created by liugd on 24-7-19.
//
#include "../headers/account_item.h"
#include "../headers/common.h"
#include <cstdlib>


int main() {

    putenv("TERM=xterm");

    //1、加载账目
    vector<AccountItem> items;
     loadDataFormFile(items);

    bool quit = false;
    while (!quit) {
        //2、读取主菜单
        showMainMenu();
        //3、键盘选择
        char key = readMenuSelection(3);
        switch (key) {
            case '1':
                //记账
                showAccountMenu();
                accounting(items);
                break;
            case '2':
                //查询
                showQueryMenu();
                 query(items);
                break;
            case '3':
                cout << "\n确认退出？(Y/N)";
                if (readQuitConfirm()) quit = true;
                break;
            default:
                break;
        }
        cout << endl;
    }
}